import Vue from 'vue'
// import VueRouter from 'vue-router'
 import VueRouter from '../vue-router'
import HomeView from '../views/HomeView.vue'
import AboutView from '../views/AboutView.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    children: [
      {
        path: 'a',//children中的路径不能有/
        component: {
          render(h) {
            return <h1>aaa</h1>
          }
        },
      },
      {
        path: 'b',
        component: {
          render(h) {
            return <h1>bbbb</h1>
          }
        },
      }
    ]
  },
  {
    path: '/about',
    name: 'about',
    component: AboutView,
    children: [
      {
        path: 'a',
        component: {
          render(h) {
            return <h1>about aaa</h1>
          }
        },
      },
      {
        path: 'b',
        component: {
          render(h) {
            return <h1> about bbbb</h1>
          }
        },
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
router.macher.addRoutes([
  {
    path: '/about',
    name: 'about',
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue'),
    children: [
      {
        path: 'c',
        component: {
          render(h) {
            return <h1>about ccccc</h1>
          }
        },
      }
    ]
  }
])
router.macher.addRoute(
  {
    path: '/xxx',
    name: 'xxxasd',
    
  }
)
// router.beforeEach((from,to,next) => {
//   setTimeout(() => {
//     console.log(1);
//     next()
//   },1000)
// })
// router.beforeEach((from, to, next) => {
//   setTimeout(() => {
//     console.log(2);
//     next()
//   }, 1000)
// })
export default router
